<?php

	$dbhost = "dunk.it.jcu.edu.au:3306";
	$username = "cp3003_09_g01";
	$password = "9000f3fcb5";
	$url = $dbhost.$username;

	$conn = mysql_connect($url, $username, $password)
		or die("Unable to connect to MySQL");

	if (!mysql_select_db($username, $conn)) {
		echo 'Could not select database';
		exit;
	}

	$sql_showAllUsers = "SELECT * FROM USER";
	$result = mysql_query($sql_showAllUsers, $conn);

	if (!$result) {
		echo "DB Error, could not query the database<br>";
		echo 'MySQL Error: ' . mysql_error();
		exit;
	}

	echo "<?xml version=\"1.0\"?>\n";
	echo "<users>\n";

	while($row = mysql_fetch_assoc($result)) {
		echo "<user>\n";
		echo "<username>" . $row['USERNAME'] . "</username>\n";
		echo "<password>" . $row['PASSWORD'] . "</password>\n";
		echo "</user>\n";
	}

	echo "</users>\n";
	
	mysql_free_result($result);

	mysql_close($conn);
?>